<template>
	<view class="">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">凭证详情</block>
		</cu-custom>
		<view class="lsc-enroll-voucher">
			<view class="lsc-info">
				<view class="lsc-info-item">
					<view class="content">
						<text class="text-grey text-bold text-lg">{{list.title}}</text>
					</view>
				</view>
				<view class="lsc-info-item">
					<view class="content">
						<text class="cuIcon-countdown text-grey"></text>
						<text class="text-grey padding-sm text-sm">报名时间：{{list.applyBeginDate}} {{list.applyBeginTime}} - {{list.applyEndDate}} {{list.applyEndTime}}</text>
					</view>
				</view>
				<view class="lsc-info-item">
					<view class="content">
						<text class="cuIcon-countdown text-grey"></text>
						<text class="text-grey padding-sm text-sm">活动时间：{{list.activityBeginDate}} {{list.activityBeginTime}} - {{list.activityEndDate}} {{list.activityEndTime}}</text>
					</view>
				</view>
				<view class="lsc-info-item">
					<view class="content">
						<text class="cuIcon-location text-grey"></text>
						<text class="text-grey padding-sm text-sm">活动地址：{{list.address}}</text>
					</view>
				</view>
				<view class="lsc-info-item">
					<view class="content margin-top">
						<text class="text-grey text-lg ">报名凭证</text>
					</view>
				</view>
				<view class="lsc-info-item">
					<view class="content margin-top">
						<image :src="(list.downloadUrl || '/static/no_pictrue.jpg')" mode="aspectFill" style="height: 500upx; background-color: #FFFFFF;"></image>
					</view>
				</view>
				<view style="border-top: 1px dashed #AAAAAA;">
					<view class="lsc-info-item margin-top">
						<view class="content">
							<text class="text-grey padding-sm text-sm">参与者：{{list.wechatNickname}}</text>
						</view>
					</view>
					<view class="lsc-info-item">
						<view class="content">
							<text class="text-grey padding-sm text-sm">报名时间：{{list.applyTime}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-blue lg" @tap="saveVoucher">下载报名凭证</button>
			
			<view class="">
				<text class="lsc-enroll-voucher-tips">1. 请不要把凭证随意分享给他人，以免被盗用</text>
				<text class="lsc-enroll-voucher-tips">2. 线下活动入场时，请展示凭证给活动发起者扫码验证</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {baseUrl} from '@/config/index';
	export default {
		data() {
			return {
				list: {}
			}
		},
		onLoad(e) {
			
			uni.request({
				url: `${baseUrl}/apply/checkApplyCertificate`,
				data: {applyId: e.id}
			})
			.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
				var [error, res]  = data;
				if(res.data.recode !== '100') {
					uni.showToast({
						icon: 'none',
						title: error,
					});
					return
				}
				this.list = res.data.data
			})
		},
		methods: {
			saveVoucher() {
				uni.downloadFile({
				    url: 'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4043889364,1020845798&fm=26&gp=0.jpg', //仅为示例，并非真实的资源
				    success: (res) => {
				        if (res.statusCode === 200) {
				            console.log('下载成功');
				        }
				    }
				});
			}
		}
	}
</script>

<style>
	.lsc-enroll-voucher {
		margin: 20upx;
		background: #FFFFFF;
	}
	.lsc-enroll-voucher .lsc-info {
		display: block;
		overflow: hidden;
		padding: 20upx 0;
	}
	.lsc-enroll-voucher .lsc-info>.lsc-info-item {
		position: relative;
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		padding: 0 15px;
		min-height: 30px;
		background-color: #ffffff;
		-webkit-box-pack: justify;
		-webkit-justify-content: space-between;
		-ms-flex-pack: justify;
		justify-content: space-between;
		-webkit-box-align: center;
		-webkit-align-items: center;
		-ms-flex-align: center;
		align-items: center;
	}
	.lsc-enroll-voucher-tips {
		font-size: 22upx;
		color: #AAAAAA;
		display: block;
		padding-top: 20upx;
	}
</style>
